<template>
    <div class="material-list">
        <div class="material-item" v-for="(item, index) in list" :key="item.libId" @click="onMaterialClick(item)">
            <div class="wrap">
                <div class="thumbnail">
                    <!-- <img :src="materalsBg" alt="">
                    <div class="play" v-if="playVisible">
                        <img src="/src/assets/images/learn-analysis-play.png" alt="">
                    </div> -->
                </div>
                <div class="progress" v-if="progressVisible">
                    <el-progress :class="item.progress == 0 ? 'none-progress' : ''" :percentage="item.progress" text-inside
                        :stroke-width="8" :color="customColor" />
                </div>
                <div class="info">
                    <div class="title">{{ item.libTitle }}（{{ item.fileList.length }}）</div>
                    <div class="date">{{ parseTime(item.createTime, '{y}年{m}月{d}日') }}</div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import materalsBg from '@/assets/images/materals-bg.png'
const { proxy } = getCurrentInstance()
const parseTime = proxy.parseTime

const props = defineProps({
    playVisible: {
        type: Boolean,
        default: false
    },
    progressVisible: {
        type: Boolean,
        default: false,
    },
    list: {
        type: Array,
        default: () => []
    }
})

const customColor = ref('#0C75F4')

const emit = defineEmits(['item-click'])
function onMaterialClick(item) {
    emit('item-click', item)
}

</script>
<style scoped lang="scss">
.material-list {
    display: flex;
    flex-wrap: wrap;
    row-gap: 31px;
    column-gap: 37px;
    padding-bottom: 20px;

    .material-item {
        flex: calc(33.33333% - 37px) 0 0;
        background: #FFFFFF;
        box-shadow: 0px 3px 6px 1px rgba(0, 0, 0, 0.16);
        cursor: pointer;
        overflow: hidden;

        .wrap {
            display: flex;
            flex-direction: column;
            height: 100%;
        }

        .thumbnail {
            flex: 1;
            position: relative;
            z-index: 0;

            img {
                display: block;
                width: 100%;
                height: 100%;
                z-index: 0;
            }

            .play {
                position: absolute;
                left: 50%;
                top: 50%;
                transform: translate(-50%, -50%);
                cursor: pointer;
                z-index: 0;
                width: 48px;
                height: 48px;
            }
        }

        .progress {
            :deep(.el-progress-bar__outer) {
                overflow: visible;

                .el-progress-bar__inner {
                    position: relative;
                    border-radius: none;

                    .el-progress-bar__innerText {
                        position: absolute;
                        top: -20px;
                        right: -24px;
                        z-index: 10;
                        color: #0C75F4;
                    }
                }
            }
        }

        &:hover {
            & .info {
                position: relative;



                &::before {
                    top: 0;
                    left: 0;
                    width: 100%;
                    height: 100%;
                    transition: width 0.2s ease-in, height 0.2s ease-in 0.2s;
                    // border-top-color: #4482D0;
                    border-right-color: #4482D0;
                }

                &::after {
                    right: 0;
                    bottom: 0;
                    width: 100%;
                    height: 100%;
                    transition: border-color 0s ease-in 0.4s, width 0.2s ease-in 0.4s, height 0.3s ease-in 0.6s;
                    border-bottom-color: #4482D0;
                    border-left-color: #4482D0;
                }
            }
        }

        .info {
            padding: 10px;
            text-align: center;
            position: relative;

            &::before,
            &::after {
                content: "";
                display: block;
                width: 0;
                height: 0;
                border: 2px solid transparent;
                box-sizing: border-box;
                position: absolute;
            }

            .title {
                color: #333;
                font-size: 16px;
                margin-bottom: 5px;
            }

            .date {
                color: #666;
                font-size: 14px;
            }
        }
    }
}
</style>